<%# locals: question_version %>

<%= set_alias_form_qved question_version %>

<%# div_tag('form_qved_', question_version) %>
<div class="question-list-item-form question-version" id="form_qved_<%= question_version.id %>">
<%= fields_for 'question_version', question_version do |f| %>

  <% if question_version.errors.any? %>
    <div class="error_explanation" id=<%= raw "question_version_err_#{question_version.id}" %>>
      <h3>继续前请修改以下<%= question_version.errors.count %>个错误</h3>
      <ul>
        <% question_version.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <%= f.hidden_field :question_type_id %>
  <dl>
    <dt>可选模板</dt>
    <dt style="margin-left:20px"><ul class="question-type-list inline-list">
      <% question_version.section.question_types.each do |question_type| %>
        <%# question_type_selection(question_version, question_type) %>
        <li><%= js_tag_option question_type.name, 
            { "set('question_version[question_type_id]','#{question_type.id}')" =>
              "form_qved_#{question_version.id}",
            submit: "form_qved_#{question_version.id}" },
            question_version.question_type == question_type %></li>
      <% end %>
    </ul></dt>
  <%# render partial: 'question_types/question_types',
      locals: { question_version: question_version, f: f } %>
  <%= f.fields_for 'data_array', question_version.data_collection do |data_f| %>
    <table class="fqv">
      <% question_version.question_type.question_fields.input.each do |question_field| %>
        <dl>
          <dt><%= question_field_label question_field, data_f %></dt>
          <dt><%= question_field_tag question_field, data_f %></dt>
        </dl>
      <% end %>
    </table>
  <% end %>
  <%# render partial: 'question_types/question_form',
      locals: { question_version: question_version, f: f } %>

<% end %>
</div>